package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;


import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.ContractVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 护理项目 Controller
 */
@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理管理")
@Slf4j
public class NursingProjectController extends BaseController {
    @Autowired
    NursingProjectService nursingProjectService;
    @GetMapping
    @ApiOperation(value = "分页查询护理项目信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理项目", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")
    })

    public ResponseResult<PageResponse<ContractVo>> selectByPage(Integer pageNum,
                                                                 Integer pageSize,
                                                                 String name,
                                                                 Integer status) {
        log.info("护理计划分页查询:");
        PageResponse<NursingProjectVo> pageInfo = nursingProjectService.selectByPage(pageNum, pageSize,name ,status);
        return success(pageInfo);
    }
    @PostMapping
    @ApiOperation(value = "新增护理项目信息")
    public ResponseResult addNursingProject(@RequestBody NursingProjectDto nursingProjectdto) {
        log.info("新增护理项目信息:{}", nursingProjectdto);
        nursingProjectService.addNursingProject(nursingProjectdto);
        return success();
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理项目信息")
    public ResponseResult<NursingProjectVo> getNursingProjectById(@PathVariable Long id) {
        log.info("根据id查询护理项目信息:{}", id);
        NursingProjectVo nursingProjectVo = nursingProjectService.getNursingProjectById(id);
        return success(nursingProjectVo);
    }

    @PutMapping("/{id}")
    @ApiOperation(value = "修改护理项目信息")
    public ResponseResult updateNursingProject(@RequestBody NursingProjectDto nursingProjectdto) {
        log.info("修改护理项目信息:{}", nursingProjectdto);
        nursingProjectService.updateNursingProject(nursingProjectdto);
        return success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理项目信息")
    public ResponseResult deleteNursingProject(@PathVariable Long id) {
        log.info("删除护理项目信息:{}", id);
        nursingProjectService.deleteNursingProject(id);
        return success();
    }
    //修改状态
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "修改护理项目状态")
    public ResponseResult updateNursingProjectStatus(@PathVariable Long id, @PathVariable Integer status) {
        log.info("修改护理项目状态:{}", id);
        nursingProjectService.updateNursingProjectStatus(id, status);
        return success();
    }
    @GetMapping("/all")
    @ApiOperation(value = "查询所有护理项目信息")
    public ResponseResult<List<NursingProjectVo>> getAllNursingProject() {
        log.info("查询所有护理项目信息");
        List<NursingProjectVo> list = nursingProjectService.getAllNursingProject();
        return success(list);
    }
}

